import { Dispatcher } from "../../../mvc/core/Dispatcher";
import { DataEvent } from "../../events/DataEvent";
import { EventName } from "../../mvc/EventName";
import { GlobalStyle } from "../../../common/global/GlobalStyle";
import { Language } from "../../../../extend/language/Language";
import { GButton } from "../../../../com/mui/controls/GButton";
import { FilterConst } from "../../../component/gconst/FilterConst";
import { GlobalClass } from "../../../../com/mui/core/GlobalClass";
import { ImagesConst } from "../../resource/ImagesConst";
import { SectarianTaskInfo } from "../../model/SectarianTaskInfo";
import { HTMLUtil } from "../../../../com/gengine/utils/HTMLUtil";
import { TaskConfig } from "../../resource/TaskConfig";
import { ColorConfig } from "../../resource/ColorConfig";
import { EffectManager } from "../../manager/EffectManager";
import { ScaleBitmap } from "../../../../com/mui/display/ScaleBitmap";
//class CanGetTaskItem
    
    export  class CanGetTaskItem /* flash.display.Sprite */
    {
        constructor()
        {
            
            this.initUI();
            return;
        }

        /* internal  */onOptBtnClickHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            Dispatcher.dispatchEvent(new DataEvent(EventName.SectarianTaskGetReq, this._task));
            return;
        }

        /* internal  */initUI(): void
        {
            this._taskName = new Object /* flash.text.TextField */();
            this._taskName.selectable = false;
            this._taskName.autoSize = flash.text.TextFieldAutoSize.CENTER;
            this._taskName.width = 60;
            this._taskName.textColor = 65280;
            this._taskName.text = "xxxxxx";
            this._taskName.y = 10;
            this._taskName.x = 25;
            addChild(this._taskName);
            this._taskExp = new Object /* flash.text.TextField */();
            this._taskExp.selectable = false;
            this._taskExp.autoSize = flash.text.TextFieldAutoSize.CENTER;
            this._taskExp.textColor = GlobalStyle.color1Uint;
            this._taskExp.width = 65;
            this._taskExp.text = "100000";
            this._taskExp.y = this._taskName.y;
            this._taskExp.x = 160;
            addChild(this._taskExp);
            this._taskItem = new Object /* flash.text.TextField */();
            this._taskItem.selectable = false;
            this._taskItem.autoSize = flash.text.TextFieldAutoSize.CENTER;
            this._taskItem.textColor = GlobalStyle.color1Uint;
            this._taskItem.width = 60;
            this._taskItem.text = Language.getString(20400);
            this._taskItem.y = this._taskName.y;
            this._taskItem.x = 275;
            addChild(this._taskItem);
            this._optBtn = new GButton();
            this._optBtn.styleName = "Button";
            this._optBtn.setSize(55, 24);
            this._optBtn.label = Language.getString(20650);
            this._optBtn.textField.filters = [FilterConst.nameGlowFilter];
            this._optBtn.y = this._taskName.y - 5;
            this._optBtn.x = 360;
            this._optBtn.addEventListener(flash.events.MouseEvent.CLICK, this.onOptBtnClickHandler);
            addChild(this._optBtn);
            this._line = GlobalClass.getScaleBitmap(ImagesConst.SplitLine);
            this._line.y = 30;
            this._line.width = this.width;
            addChild(this._line);
            return;
        }

        public updateData(arg1: SectarianTaskInfo, arg2: Boolean): void
        {
            this._task = arg1;
            this._taskName.htmlText = HTMLUtil.addColor(TaskConfig.instance.getTaskName(arg1.task.code), ColorConfig.instance.getItemColor(arg1.color).color);
            this._taskExp.text = arg1.rewardExp + "";
            this._taskItem.text = arg1.rewardItem;
            this._optBtn.enabled = arg2;
            if (this._optBtn.enabled) 
            {
                EffectManager.glowFilterReg(this._optBtn, [FilterConst.guideTipsFilter]);
            }
            return;
        }

        public dispose(): void
        {
            this._task = null;
            EffectManager.glowFilterUnReg(this._optBtn);
            return;
        }

        public /* override */ get width(): number
        {
            return 450;
        }

        public /* override */ get height(): number
        {
            return 32;
        }

        /* internal */ /* var */_taskName: Object /* flash.text.TextField */;

        /* internal */ /* var */_taskExp: Object /* flash.text.TextField */;

        /* internal */ /* var */_taskItem: Object /* flash.text.TextField */;

        /* internal */ /* var */_optBtn: GButton;

        /* internal */ /* var */_line: ScaleBitmap;

        /* internal */ /* var */_task: SectarianTaskInfo;
    }
